package KAUFLICK;

import java.awt.Graphics;
import java.awt.Point;
import java.util.*;

public class BallManager {
	final double FRICTION_FACTOR = 0.5;
	final double GRAVIT_ACCEL = 9.81;		// Gravitational acceleration (unit: m/(s^2) )
	final double IMPULSE_TIME = 0.1;		// flicking impuls period (unit: sec)
	final double PIXEL_METER_RATIO = 1;		// pixel-meter scaler
	
	ArrayList<Ball> BallList;
	
	public BallManager() {
		BallList = new ArrayList<Ball>();
	}
	
	public void newBall() {
		Ball b = new Ball();
		BallList.add(b);
	}
	public void newBall(String p_name, int p_size, Point p_pos, double p_weight) {
		Ball b = new Ball(p_name, p_size, p_pos, p_weight);
		BallList.add(b);
	}
	public void draw(Graphics g) {
		for (Ball b : BallList)
			b.draw(g);
	}
	public void flick(Point start, Point end) {
		double f = 0;		// (unit: N)
		double length_h;	// width (unit: pixel)
		double length_v;	// height (unit: pixel)
		double length_s;	// slope (unit: pixel)
		double degree;		// (unit: degree)
		
		length_h = end.x - start.x;
		length_v = end.y - start.y;
		
		length_s = Math.sqrt((Math.pow(length_h, 2) + Math.pow(length_v, 2))); // determine magnitude
		degree =  Math.atan(length_v / length_h);
	}
	private void impulse(Ball b, double length_s) {	// calculate acceleration from force 
		double a;
		a = length_s / b.getWeight();
		double velocity = a * IMPULSE_TIME;
	}	
}
